package com.yunsoft.notice.service.controller;

import com.fld.central.common.model.protocol.ResultDto;
import com.yunsoft.notice.api.api.NotifyRpc;
import com.yunsoft.notice.api.dto.sms.SmsMessage;
import com.yunsoft.notice.api.enums.SmsEnum;
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author yangyunfeng
 * @description
 * @date AD 2023/10/26
 */
@RestController
@RequestMapping("/message")
public class MessageController {

  @Autowired
  private NotifyRpc noticeRpc;


  @PostMapping("/test")
  public ResultDto<String> test(@RequestParam("code") String code) {
    return ResultDto.ok("test");
  }

  @GetMapping("/send")
  public ResultDto<String> send(@RequestParam("code") String code){
    SmsMessage smsMessage = new SmsMessage();
    List<String> array = new ArrayList<>();
    array.add("13265797978");
    smsMessage.setPhones(array);
    smsMessage.setType(SmsEnum.NOTICE);
    smsMessage.setContent("短信{code}");
    smsMessage.setTemplateCode(code);
    smsMessage.setService("com.service.com");
    ResultDto<String> send = noticeRpc.send(smsMessage);
    return ResultDto.ok(send.getData());
  }

}
